/*
* ======================================================================
* ----------------------------------------------------------------------
* cmnviewer:    Comment sagita Viewer
* Author:        sagita
* Website:        http://www.sagitasoft.com
* ----------------------------------------------------------------------
* You may use and/or modify the codes below and its associated files
* as long as you leave the author credit remain intact
* ----------------------------------------------------------------------
* ======================================================================
*/


// check container element
// ---------------------------------------------------------------------
if (document.getElementById('cmnvOpener') == null) {
    document.write('<input id="cmnvOpener" name="cmnvOpener" type="button" value="Show the content only" onclick="cmnvToggleDisplay(\'content\',\'10%\',\'80%\',\'10%\',\'5%\',\'90%\',\'5%\');" />');
}


var cmnvFadeTime = 350;
var cmnvContentLoaded = false;
var cmnvControllerAdded = false;
var cmnvALEadded;

function cmnvPutStyle() {
    var cmnvStyleRules = ''
    +'#cmnvOpener { border-radius:7px; -moz-border-radius:7px; -webkit-border-radius:7px; -khtml-border-radius:7px; } '
    +'div#cmnvBgContainer, div#cmnvContentWindow { position:fixed; }'
    +'div#cmnvBg, div#cmnvControlBtnContainer, div#cmnvContentContainer, div#cmnvContent, div#cmnvContentWindowBg { position:absolute; }'
    +'div#cmnvBgContainer { z-index:10000000; '
        +'top:0; right:0; bottom:0; left:0; background:none repeat scroll 0 0 transparent; }'
    +'div#cmnvBg { top:0; right:0; bottom:0; left:0; background-color:#000; opacity:0.7; filter:alpha(opacity=70); }'
    +'div#cmnvContentWindow { z-index:10000002; '
        +'border:none solid #585858; background-color:#585858; '
        +'border-radius:8px; -moz-border-radius:8px; -webkit-border-radius:8px; -khtml-border-radius:8px; '
        +'box-shadow:0 0 20px #000; -moz-box-shadow:0 0 20px #000; -webkit-box-shadow:0 0 20px #000; -khtml-box-shadow:0 0 20px #000; }'
    +'div#cmnvControlBtnContainer { top:0; right:0; bottom:auto; left:0; z-index:10000005; '
        +'margin:0; padding:0 15px 0 10px; height:23px; '
        +'background-color:transparent; border-bottom:none; '
        +'font-family:"Trebuchet MS",Verdana,Arial,sans-serif; font-weight:normal; font-size:13px; line-height:20px; vertical-align:baseline; }'
    +'a#cmnvAL, a#cmnvClose { cursor:pointer; text-decoration:none; margin:0; padding:0; color:#000; opacity:0.4; filter:alpha(opacity=40); }'
    +'a#cmnvAL { float:left; }'
    +'a#cmnvClose { float:right; '
        +'border:1px solid #999; border-top:none; background-color:transparent; '
        +'border-radius:0 0 4px 4px; -moz-border-radius:0 0 4px 4px; -webkit-border-radius:0 0 4px 4px; -khtml-border-radius:0 0 4px 4px; '
        +'font-weight:bold; line-height:18px; padding:0 15px; }'
    +'a#cmnvAL:hover, a#cmnvClose:hover { opacity:1; filter:alpha(opacity=100); }'
    +'a#cmnvClose:hover { border-color:#000; }'
    +'div#cmnvContentContainer { top:24px; right:0; bottom:7px; left:0; z-index:10000004; overflow:auto; '
        +'background-color:#585858; border-radius:7px; -moz-border-radius:7px; -webkit-border-radius:7px; -khtml-border-radius:7px; }'
    +'div#cmnvContent { background-color:#585858; margin:10px; overflow:hidden; word-wrap:break-word; z-index:10000005; }'
    +'';
    var cmnvSE = document.createElement('style');
    cmnvSE.type = 'text/css';
    if (!!(window.attachEvent && !window.opera)) {
        cmnvSE.styleSheet.cssText = cmnvStyleRules;
    } else {
        var cmnvST = document.createTextNode(cmnvStyleRules);
        cmnvSE.appendChild(cmnvST);
    }
    document.getElementsByTagName('head')[0].appendChild(cmnvSE);
}

cmnvPutStyle();

var cmnvHTMLtext = ''
+'<div id="cmnvBgContainer" style="display:none; opacity:0; filter:alpha(opacity=0);">'
    +'<div id="cmnvBg">'
    +'</div>'
+'</div>'
+'<div id="cmnvContentWindow" style="display:none; opacity:0; filter:alpha(opacity=0);">'
    +'<div id="cmnvControlBtnContainer">'
        +'<a id="cmnvClose" title="Close">x</a>'
    +'</div>'
    +'<div id="cmnvContentContainer">'
        +'<div id="cmnvContent">'
        +'</div>'
    +'</div>'
+'</div>'
+'';
document.write(cmnvHTMLtext);

var cmnvBCE = document.getElementById('cmnvBgContainer');
var cmnvBE = document.getElementById('cmnvBg');
var cmnvCWE = document.getElementById('cmnvContentWindow');
var cmnvCBCE = document.getElementById('cmnvControlBtnContainer');
var cmnvCE = document.getElementById('cmnvContent');
var cmnvALE = document.createElement('a');
cmnvALE.id = unescape('%63%6D%6E%76%41%4C');
cmnvALE.href = unescape('%68%74%74%70%3A%2F%2F%77%77%77%2E%67%6F%67%65%6C%6C%2E%74%6B%2F%32%30%31%32%2F%30%38%2F%77%69%64%67%65%74%2D%62%6C%6F%67%2E%68%74%6D%6C');
cmnvALE.title = unescape('%56%69%65%77%20%62%75%74%74%6F%6E');
cmnvALE.setAttribute('target','_blank');
var cmnvALTE = document.createTextNode(unescape('%42%79%20%53%61%67%69%74%61'));
cmnvALE.appendChild(cmnvALTE);
cmnvCBCE.insertBefore(cmnvALE,cmnvCBCE.firstChild);
var cmnvUserContentElmId; var l; var w; var r; var t; var h; var b;

function cmnvToggleFade(eid) {
    var element = document.getElementById(eid);
    if (element == null) { return; }
    if(element.FadeState == null) {
        if (element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1') {
            element.FadeState = 2;
        } else {
            element.FadeState = -2;
        }
    }
    if (element.FadeState == 1 || element.FadeState == -1) {
        element.FadeState = element.FadeState == 1 ? -1 : 1;
        element.FadeTimeLeft = cmnvFadeTime - element.FadeTimeLeft;
    } else {
        element.FadeState = element.FadeState == 2 ? -1 : 1;
        element.FadeTimeLeft = cmnvFadeTime;
        setTimeout('cmnvAnimFade('+new Date().getTime()+',\''+eid+'\')', 4);
    }
}

function cmnvAnimFade(lastTick, eid) {
    var curTick = new Date().getTime();
    var elapsedTicks = curTick - lastTick;
    var element = document.getElementById(eid);
    if(element.FadeTimeLeft <= elapsedTicks) {
        element.style.opacity = element.FadeState == 1 ? '1' : '0';
        element.style.filter = 'alpha(opacity='+(element.FadeState == 1 ? '100' : '0')+')';
        element.FadeState = element.FadeState == 1 ? 2 : -2;
        return;
    }
    element.FadeTimeLeft -= elapsedTicks;
    var newOpVal = element.FadeTimeLeft/cmnvFadeTime;
    if (element.FadeState == 1) {
        newOpVal = 1 - newOpVal;
    }
    element.style.opacity = newOpVal;
    element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
    setTimeout('cmnvAnimFade('+curTick+',\''+eid+'\')', 4);
}

function cmnvToggleDisplay(cmnvUserContentElmId,l,w,r,t,h,b) {
    var cmnvUserContentHTML = document.getElementById(cmnvUserContentElmId).innerHTML;
    var cmnvFunctionCall = 'cmnvToggleDisplay(\''+cmnvUserContentElmId+'\',\''+l+'\',\''+w+'\',\''+r+'\',\''+t+'\',\''+h+'\',\''+b+'\')';
    document.getElementById('cmnvClose').setAttribute('onclick',cmnvFunctionCall);
    if (cmnvBCE.style.display == 'none') {
        if (!cmnvContentLoaded) {
            cmnvCE.innerHTML = cmnvUserContentHTML;
            cmnvContentLoaded = true;
        }
        var    cmnvOpenerElmLength = document.getElementsByName('cmnvOpener').length;
        var i = 0;
        for (i = 0; i < cmnvOpenerElmLength; i++) {
            document.getElementsByName('cmnvOpener')[i].style.display = 'none';
        }
        cmnvCWE.style.left = l;
        cmnvCWE.style.width = w;
        cmnvCWE.style.right = r;
        cmnvCWE.style.top = t;
        cmnvCWE.style.height = h;
        cmnvCWE.style.bottom = b;
        cmnvBCE.style.display = 'block';
        cmnvCWE.style.display = 'block';
        cmnvBE.setAttribute('onclick',cmnvFunctionCall);
        cmnvToggleFade('cmnvBgContainer');
        setTimeout('cmnvToggleFade(\'cmnvContentWindow\')', cmnvFadeTime/2);
    } else {
        cmnvBE.setAttribute('onclick','');
        cmnvToggleFade('cmnvContentWindow');
        setTimeout('cmnvToggleFade(\'cmnvBgContainer\')', cmnvFadeTime/2);
        setTimeout('cmnvHide()', cmnvFadeTime);
    }
}

function cmnvHide() {
    cmnvCWE.style.display = 'none';
    cmnvBCE.style.display = 'none';
    var    cmnvOpenerElmLength = document.getElementsByName('cmnvOpener').length;
    var i = 0;
    for (i = 0; i < cmnvOpenerElmLength; i++) {
        document.getElementsByName('cmnvOpener')[i].style.display = 'block';
    }
}